#pragma once 

#include <system_error>

namespace memdb {
namespace error {

enum memdb_errno {
	ok = 0,
	error = 1,

  table_not_exists,
  table_exists,

  key_not_exists,
  key_exists,

  db_not_exists,
  db_exists,

  fs_create_directory_error,

  meta_info_absent,

	max_error_no,
};

class MemdbErrorCategory : public std::error_category {
public:
	const char * name() const noexcept override;
  std::string message(int ev) const override;
	//std::error_condition default_error_condition(int ev) const noexcept override;
};



inline const std::error_category & MemdbCategory() {
	static MemdbErrorCategory instance;
	return instance;
}

inline std::error_code make_error_code(memdb_errno errc){
	return errc != ok ? std::error_code(static_cast<int>(errc), MemdbCategory()) : std::error_code();
}

inline std::error_condition make_error_condition(memdb_errno errc){
	return std::error_condition(static_cast<int>(errc), MemdbCategory());
}

}//namespace error
}//namespace memdb

namespace std
{
  template <>
  struct is_error_code_enum<memdb::error::memdb_errno> : public true_type {};

}//namespace std
